/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sysprojectmg.conexion;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
 *
 * @author Instructor
 */
public class ConectaDB {
    private Connection objconn;
    ResourceBundle recursos = ResourceBundle.getBundle("sysprojectmg.conexion.database");

    public Connection getAcceso() throws Exception {
        Class.forName(recursos.getString("driver"));

        objconn = DriverManager.getConnection(
                recursos.getString("url"),
                recursos.getString("username"),
                recursos.getString("password"));
        
//        if (objconn != null){
//            System.out.println("se pudo conectar "+objconn);
//        }


        return objconn;
    }
    public void cerrarConexion() throws SQLException {
        if (objconn == null || objconn.isClosed()) {
            return;
        }
        objconn.close();
    }
}
